home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Database How-To / Visual Basic 4 Database - How-to (The Waite Group)(1995).iso / control.fr_ / control.fr
Text File  |  1995-04-03  |  15KB  |  465 lines

  1. VERSION 4.00
  2. Begin VB.Form frmControl 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Set Report Printing Options"
  5.    ClientHeight    =   5025
  6.    ClientLeft      =   1050
  7.    ClientTop       =   1530
  8.    ClientWidth     =   6540
  9.    ForeColor       =   &H00000000&
  10.    Height          =   5430
  11.    Left            =   990
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5025
  14.    ScaleWidth      =   6540
  15.    Top             =   1185
  16.    Width           =   6660
  17.    Begin VB.Timer tmrReady 
  18.       Interval        =   500
  19.       Left            =   2760
  20.       Top             =   4320
  21.    End
  22.    Begin VB.CommandButton cmdPrint 
  23.       Caption         =   "Print &Report"
  24.       Enabled         =   0   'False
  25.       Height          =   495
  26.       Left            =   3720
  27.       TabIndex        =   21
  28.       Top             =   4320
  29.       Width           =   1215
  30.    End
  31.    Begin VB.CommandButton cmdQuit 
  32.       Caption         =   "&Quit"
  33.       Height          =   495
  34.       Left            =   5040
  35.       TabIndex        =   22
  36.       Top             =   4320
  37.       Width           =   1215
  38.    End
  39.    Begin VB.HScrollBar hsbCopies 
  40.       Height          =   270
  41.       LargeChange     =   10
  42.       Left            =   3000
  43.       Max             =   100
  44.       Min             =   1
  45.       TabIndex        =   13
  46.       Top             =   3000
  47.       Value           =   1
  48.       Width           =   1935
  49.    End
  50.    Begin VB.ComboBox lstFileType 
  51.       BackColor       =   &H00FFFFFF&
  52.       Height          =   300
  53.       Left            =   2160
  54.       Style           =   2  'Dropdown List
  55.       TabIndex        =   20
  56.       Top             =   3720
  57.       Width           =   2775
  58.    End
  59.    Begin VB.TextBox txtReportToPrint 
  60.       BackColor       =   &H00C0C0C0&
  61.       Height          =   285
  62.       Left            =   2160
  63.       TabIndex        =   1
  64.       Top             =   360
  65.       Width           =   2775
  66.    End
  67.    Begin VB.CommandButton cmdNewReport 
  68.       Caption         =   "&Select File"
  69.       Height          =   300
  70.       Left            =   5040
  71.       TabIndex        =   2
  72.       Top             =   360
  73.       Width           =   1215
  74.    End
  75.    Begin VB.CommandButton cmdFileName 
  76.       Caption         =   "Change &File"
  77.       Height          =   300
  78.       Left            =   5040
  79.       TabIndex        =   18
  80.       Top             =   3360
  81.       Width           =   1215
  82.    End
  83.    Begin VB.TextBox txtFileName 
  84.       BackColor       =   &H00C0C0C0&
  85.       Height          =   285
  86.       Left            =   2160
  87.       TabIndex        =   17
  88.       Top             =   3360
  89.       Width           =   2775
  90.    End
  91.    Begin VB.ComboBox lstDestination 
  92.       BackColor       =   &H00FFFFFF&
  93.       Height          =   300
  94.       Left            =   2160
  95.       Style           =   2  'Dropdown List
  96.       TabIndex        =   15
  97.       Top             =   2640
  98.       Width           =   2775
  99.    End
  100.    Begin VB.TextBox txtCopies 
  101.       BackColor       =   &H00C0C0C0&
  102.       Height          =   285
  103.       Left            =   2160
  104.       ReadOnly        =   -1  'True
  105.       TabIndex        =   12
  106.       TabStop         =   0   'False
  107.       Text            =   "1"
  108.       Top             =   3000
  109.       Width           =   735
  110.    End
  111.    Begin Threed.SSFrame frmConnect 
  112.       Height          =   1695
  113.       Left            =   360
  114.       TabIndex        =   23
  115.       Top             =   720
  116.       Width           =   4935
  117.       _version        =   65536
  118.       _extentx        =   8705
  119.       _extenty        =   2990
  120.       _stockprops     =   14
  121.       caption         =   "Connect String"
  122.       forecolor       =   -2147483640
  123.       Begin VB.TextBox txtConnect 
  124.          BackColor       =   &H00FFFFFF&
  125.          Height          =   285
  126.          Index           =   0
  127.          Left            =   1800
  128.          TabIndex        =   4
  129.          Top             =   240
  130.          Width           =   2775
  131.       End
  132.       Begin VB.TextBox txtConnect 
  133.          BackColor       =   &H00FFFFFF&
  134.          Height          =   285
  135.          Index           =   1
  136.          Left            =   1800
  137.          TabIndex        =   6
  138.          Top             =   600
  139.          Width           =   2775
  140.       End
  141.       Begin VB.TextBox txtConnect 
  142.          BackColor       =   &H00FFFFFF&
  143.          Height          =   285
  144.          Index           =   2
  145.          Left            =   1800
  146.          TabIndex        =   8
  147.          Top             =   960
  148.          Width           =   2775
  149.       End
  150.       Begin VB.TextBox txtConnect 
  151.          BackColor       =   &H00FFFFFF&
  152.          Height          =   285
  153.          Index           =   3
  154.          Left            =   1800
  155.          TabIndex        =   10
  156.          Top             =   1320
  157.          Width           =   2775
  158.       End
  159.       Begin VB.Label Label1 
  160.          Alignment       =   1  'Right Justify
  161.          BackColor       =   &H00C0C0C0&
  162.          Caption         =   "&Data Source Name:"
  163.          Height          =   255
  164.          Left            =   240
  165.          TabIndex        =   3
  166.          Top             =   240
  167.          Width           =   1500
  168.       End
  169.       Begin VB.Label Label2 
  170.          Alignment       =   1  'Right Justify
  171.          BackColor       =   &H00C0C0C0&
  172.          Caption         =   "&User ID:"
  173.          Height          =   255
  174.          Left            =   240
  175.          TabIndex        =   5
  176.          Top             =   600
  177.          Width           =   1500
  178.       End
  179.       Begin VB.Label Label4 
  180.          Alignment       =   1  'Right Justify
  181.          BackColor       =   &H00C0C0C0&
  182.          Caption         =   "&Password:"
  183.          Height          =   255
  184.          Left            =   240
  185.          TabIndex        =   7
  186.          Top             =   960
  187.          Width           =   1500
  188.       End
  189.       Begin VB.Label Label5 
  190.          Alignment       =   1  'Right Justify
  191.          BackColor       =   &H00C0C0C0&
  192.          Caption         =   "D&B Qualifier:"
  193.          Height          =   255
  194.          Left            =   240
  195.          TabIndex        =   9
  196.          Top             =   1320
  197.          Width           =   1500
  198.       End
  199.    End
  200.    Begin VB.Label lblFileType 
  201.       Alignment       =   1  'Right Justify
  202.       BackColor       =   &H00C0C0C0&
  203.       Caption         =   "&Output file type:"
  204.       Height          =   255
  205.       Left            =   360
  206.       TabIndex        =   19
  207.       Top             =   3720
  208.       Width           =   1695
  209.    End
  210.    Begin VB.Label Label10 
  211.       Alignment       =   1  'Right Justify
  212.       BackColor       =   &H00C0C0C0&
  213.       Caption         =   "Report to print:"
  214.       Height          =   255
  215.       Left            =   360
  216.       TabIndex        =   0
  217.       Top             =   360
  218.       Width           =   1695
  219.    End
  220.    Begin MSComDlg.CommonDialog cdFileName 
  221.       Left            =   2040
  222.       Top             =   4320
  223.       _version        =   65536
  224.       _extentx        =   847
  225.       _extenty        =   847
  226.       _stockprops     =   0
  227.       dialogtitle     =   "Report File Destination Name"
  228.       filter          =   "Text File (*.txt)|*.txt|Document (*.doc)|*.doc|All Files (*.*)|*.*"
  229.    End
  230.    Begin VB.Label lblFileName 
  231.       Alignment       =   1  'Right Justify
  232.       BackColor       =   &H00C0C0C0&
  233.       Caption         =   "Output file name:"
  234.       Height          =   255
  235.       Left            =   360
  236.       TabIndex        =   16
  237.       Top             =   3360
  238.       Width           =   1695
  239.    End
  240.    Begin Crystal.CrystalReport CrystalReport1 
  241.       Left            =   1320
  242.       Top             =   4320
  243.       _extentx        =   741
  244.       _extenty        =   741
  245.       _stockprops     =   0
  246.       reportfilename  =   ""
  247.       destination     =   0
  248.       windowleft      =   100
  249.       windowtop       =   100
  250.       windowwidth     =   490
  251.       windowheight    =   300
  252.       windowtitle     =   ""
  253.       windowborderstyle=   2
  254.       windowcontrolbox=   -1  'True
  255.       windowmaxbutton =   -1  'True
  256.       windowminbutton =   -1  'True
  257.       copiestoprinter =   1
  258.       printfilename   =   ""
  259.       printfiletype   =   0
  260.       selectionformula=   ""
  261.       groupselectionformula=   ""
  262.       connect         =   ""
  263.       username        =   ""
  264.    End
  265.    Begin VB.Label Label9 
  266.       Alignment       =   1  'Right Justify
  267.       BackColor       =   &H00C0C0C0&
  268.       Caption         =   "&Print destination:"
  269.       ForeColor       =   &H00000000&
  270.       Height          =   255
  271.       Left            =   360
  272.       TabIndex        =   14
  273.       Top             =   2640
  274.       Width           =   1695
  275.    End
  276.    Begin VB.Label lblCopies 
  277.       Alignment       =   1  'Right Justify
  278.       BackColor       =   &H00C0C0C0&
  279.       Caption         =   "&Number of copies:"
  280.       Height          =   255
  281.       Left            =   360
  282.       TabIndex        =   11
  283.       Top             =   3000
  284.       Width           =   1695
  285.    End
  286. End
  287. Attribute VB_Name = "frmControl"
  288. Attribute VB_Creatable = False
  289. Attribute VB_Exposed = False
  290. Option Explicit
  291.  
  292. Private Sub cmdFileName_Click()
  293.     cdFileName.DefaultExt = "txt"
  294.     cdFileName.DialogTitle = "Report File Destination Name"
  295.     cdFileName.Filter = "Text File (*.txt)|*.txt|Document (*.doc)|*.doc|All Files (*.*)|*.*"
  296.     cdFileName.ShowOpen
  297.     txtFileName.Text = cdFileName.FileName
  298. End Sub
  299.  
  300. Private Sub cmdNewReport_Click()
  301.     cdFileName.DefaultExt = "rpt"
  302.     cdFileName.DialogTitle = "Select Report File"
  303.     cdFileName.Filter = "Report File (*.rpt)|*.rpt|All Files (*.*)|*.*"
  304.     cdFileName.ShowOpen
  305.     txtReportToPrint.Text = cdFileName.FileName
  306. End Sub
  307.  
  308. Private Sub cmdPrint_Click()
  309.     'Since the button is enabled, we're okay to print
  310.     CrystalReport1.Action = 1
  311. End Sub
  312.  
  313. Private Sub cmdQuit_Click()
  314.     End
  315. End Sub
  316.  
  317. Private Sub Form_Load()
  318.     'Build the list control lists
  319.     lstDestination.AddItem "0: Print window"
  320.     lstDestination.AddItem "1: Printer"
  321.     lstDestination.AddItem "2: File"
  322.     lstDestination.ListIndex = 0
  323.     
  324.     lstFileType.AddItem "0: Fixed field width"
  325.     lstFileType.AddItem "1: Tab delimited, with quotes"
  326.     lstFileType.AddItem "2: Space delimited"
  327.     lstFileType.AddItem "3: Data interchange format (DIF)"
  328.     lstFileType.AddItem "4: Comma delimited"
  329.     lstFileType.AddItem "5: Reserved"
  330.     lstFileType.AddItem "6: Tab delimited, no quotes"
  331.     
  332.     'Set the visibility of the appropriate controls
  333.     lstDestination_Click
  334.     
  335.     'Center the form
  336.     frmControl.Move (Screen.Width - frmControl.Width) / 2, (Screen.Height - frmControl.Height) / 2
  337. End Sub
  338.  
  339. Private Sub hsbCopies_Change()
  340.     txtCopies.Text = hsbCopies.Value
  341.     CrystalReport1.CopiesToPrinter = hsbCopies.Value
  342. End Sub
  343.  
  344. Private Sub lstDestination_Click()
  345.     'Enable appropriate options, based on ListIndex
  346.     Select Case lstDestination.ListIndex
  347.         Case 0 'Print to window
  348.             lblFileName.ForeColor = &H404040
  349.             txtFileName.Enabled = False
  350.             txtFileName.Text = ""
  351.             cmdFileName.Enabled = False
  352.             
  353.             lblFileType.ForeColor = &H404040
  354.             lstFileType.Enabled = False
  355.             lstFileType.Text = ""
  356.             
  357.             lblCopies.ForeColor = &H404040
  358.             txtCopies.Enabled = False
  359.             txtCopies.Text = 1
  360.             hsbCopies.Value = 1
  361.         
  362.         Case 1 'Print to printer
  363.             lblFileName.ForeColor = &H404040
  364.             txtFileName.Enabled = False
  365.             txtFileName.Text = ""
  366.             cmdFileName.Enabled = False
  367.             
  368.             lblFileType.ForeColor = &H404040
  369.             lstFileType.Enabled = False
  370.             lstFileType.Text = ""
  371.             
  372.             lblCopies.ForeColor = &H0&
  373.             txtCopies.Enabled = True
  374.             txtCopies.Text = 1
  375.             hsbCopies.Value = 1
  376.         
  377.         Case 2 'Print to file
  378.             lblFileName.ForeColor = &H0&
  379.             txtFileName.Enabled = True
  380.             txtFileName.Text = ""
  381.             cmdFileName.Enabled = True
  382.             
  383.             lblFileType.ForeColor = &H0&
  384.             lstFileType.Enabled = True
  385.             lstFileType.Text = ""
  386.             
  387.             lblCopies.ForeColor = &H404040
  388.             txtCopies.Enabled = False
  389.             txtCopies.Text = 1
  390.             hsbCopies.Value = 1
  391.     End Select
  392. End Sub
  393.  
  394. Private Sub lstFileType_Click()
  395.     'Can't use the Crystal Reports reserved value
  396.     If lstFileType.ListIndex = 5 Then
  397.         MsgBox "Reserved value not available. Please select another."
  398.         lstFileType.ListIndex = 0
  399.         lstFileType.Text = ""
  400.     Else
  401.         CrystalReport1.PrintFileType = lstFileType.ListIndex
  402.     End If
  403. End Sub
  404.  
  405. Private Sub tmrReady_Timer()
  406.     'Check every half second to see if report is ready to print
  407.     'If it is, enable the Print Report command button
  408.     Dim Ready As Boolean
  409.     
  410.     Ready = True
  411.     If Len(txtReportToPrint.Text) < 5 Then
  412.         Ready = False
  413.     End If
  414.     If lstDestination.ListIndex = 2 And (txtFileName.Text = "" Or lstFileType.Text = "") Then
  415.         Ready = False
  416.     End If
  417.     
  418.     cmdPrint.Enabled = IIf(Ready, True, False)
  419. End Sub
  420.  
  421. Private Sub txtConnect_LostFocus(Index As Integer)
  422.     'Something in one of the control array boxes changed,
  423.     'so rebuild the connect string
  424.     Dim Connect As String
  425.     
  426.     If Len(txtConnect(0).Text) Then
  427.         Connect = "DSN=" & txtConnect(0).Text & ";"
  428.     End If
  429.     If Len(txtConnect(1).Text) Then
  430.         Connect = Connect & "UID=" & txtConnect(1).Text & ";"
  431.     End If
  432.     If Len(txtConnect(2).Text) Then
  433.         Connect = Connect & "PWD=" & txtConnect(2).Text & ";"
  434.     End If
  435.     If Len(txtConnect(3).Text) Then
  436.         Connect = Connect & "DSQ=" & txtConnect(3).Text & ";"
  437.     End If
  438.     
  439.     CrystalReport1.Connect = Connect
  440. End Sub
  441.  
  442. Private Sub txtReportToPrint_Change()
  443.     'Contents have changed, so reset cmdNewReport caption
  444.     If Len(txtReportToPrint.Text) Then
  445.         cmdNewReport.Caption = "&Change File"
  446.         CrystalReport1.ReportFileName = txtReportToPrint.Text
  447.     Else
  448.         cmdNewReport.Caption = "&Select File"
  449.         CrystalReport1.ReportFileName = ""
  450.     End If
  451. End Sub
  452.  
  453. Private Sub txtFileName_Change()
  454.     'Contents have changed, so reset cmdFileName caption
  455.     'and set the PrintFileName property
  456.     If Len(txtFileName.Text) Then
  457.         cmdFileName.Caption = "Change &File"
  458.         CrystalReport1.PrintFileName = txtFileName.Text
  459.     Else
  460.         cmdFileName.Caption = "Select &File"
  461.         CrystalReport1.PrintFileName = ""
  462.     End If
  463. End Sub
  464.  
  465.